package com.rc.saas.tenant.interceptor.process;

import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.util.TablesNamesFinder;

import javax.naming.OperationNotSupportedException;
import java.util.List;

public class SelectProcess {
    //private SubSelectProcess subSelectProcess;

    public static String addWhere(Select select) throws OperationNotSupportedException {
        TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
        List<String> tableList = tablesNamesFinder.getTableList(select);
        if (tableList.size() == 0) {
            return select.toString();
        }

        //如果已有tenantCode条件不再增加
        SubSelectProcess.addCondition(select.getSelectBody());

        return select.toString();
    }

    //@Resource
    //public void setSubSelectProcess(SubSelectProcess subSelectProcess) {
    //    this.subSelectProcess = subSelectProcess;
    //}
}
